# To change this template, choose Tools | Templates
# and open the template in the editor.

"""
    qsi
    ====================================

    The app's main module.
    
    Access this app on the following url:
        https://qsi-trackit.appspot.com
        http://qsi.pymake.com
    
"""


__author__="pykuta"
__date__ ="$Jul 11, 2013 10:36:48 PM$"

import sys
import os
import re
import webapp2
from webapp2 import Route
import os
from jinja2.filters import do_pprint
from err_handlers import *

if 'lib' not in sys.path:
    sys.path[0:0] = ['lib']

DEBUG = os.environ.get('SERVER_SOFTWARE', '').startswith('Dev')

routes = [
    Route(r'/', handler='handlers.PageHandler:root', name='pages-root'),
    #for hiding and redirecting the external providers user req login
    Route(r'/login', handler='handlers.ExternalAccounts', name='check_login'),
    #for testing if the myauthorise() decorator works
    Route(r'/testpage', handler='handlers.TestPage', name='testpage'),
    # Wipe DS
    Route(r'/tasks/whip-ds', handler='handlers.WipeDSHandler', name='whip-ds'),
    ]

config = {
    'webapp2_extras.sessions': {
        'secret_key': 'c7effgd7658dhk1fbcc30942a2ceebd66f70d1f1'
    },
    'webapp2_extras.auth': {
        #  'user_model': 'models.User',
        'user_attributes': ['displayName', 'email'],
        },
    'webapp2_extras.jinja2': {
        'filters': {
            'do_pprint': do_pprint,
            },
        },
    }


application = webapp2.WSGIApplication(routes, debug=DEBUG, config=config)
application.error_handlers[404] = handle_404
application.error_handlers[500] = handle_500

